<?php
class CategoryWidget  extends CWidget{
    
	//输出字符串
	private $out = '';
    
    private $controller= '';
    
    private $action= '';
    
    public $category = '';

	public function init(){
        $this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id; 
	}

	public function run(){
        $this->generateAd();
		echo $this->out;
	}

    public function generateAd(){
        //ios
        if(strtolower($this->category) == 'ios'){//ios
            $this->out .= <<<ADamazon
                <div class='' style='padding:2px 0px'>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=18XSTZJ7466VVKY5A0R2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=0ZZ6QB4NZNPBBGFE1XG2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=0MYHTGGE85NRFT2HWD82&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                </div>
ADamazon;
        }else if(strtolower($this->category) == ''){//empty
            $this->out .= <<<ADamazon
                <div class='' style='padding:2px 0px'>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=07TX0X2FRE3ABTG53EG2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=18XSTZJ7466VVKY5A0R2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=05C7BS1Y9ME63VDSN9G2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                </div>
ADamazon;
        }else if(strtolower($this->category) != ''){//not empty
            $this->out .= <<<ADamazon
                <div class='' style='padding:2px 0px'>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=05C7BS1Y9ME63VDSN9G2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=1K3RQR56FPEJFEZ8R9R2&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                    <iframe src="http://rcm-cn.amazon-adsystem.com/e/cm?t=gowhich-23&o=28&p=12&l=ur1&category=books&banner=17QS543P7Q3HA98XZV82&f=ifr" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
                </div>
ADamazon;
        }
    }
}



